home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 December / maximum-cd-2009-12.iso / DiscContents / gimp-2.7.0-i686-setup.exe / {app} / share / gimp / 2.0 / scripts / swirly-pattern.scm < prev    next >
Encoding:
Text File  |  2009-08-19  |  2.9 KB  |  94 lines

  1. ; GIMP - The GNU Image Manipulation Program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ;
  4. ; Pattern00 --- create a swirly tileable pattern
  5. ; Copyright (C) 1997 Federico Mena Quintero
  6. ; federico@nuclecu.unam.mx
  7. ;
  8. ; This program is free software: you can redistribute it and/or modify
  9. ; it under the terms of the GNU General Public License as published by
  10. ; the Free Software Foundation; either version 3 of the License, or
  11. ; (at your option) any later version.
  12. ;
  13. ; This program is distributed in the hope that it will be useful,
  14. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. ; GNU General Public License for more details.
  17. ;
  18. ; You should have received a copy of the GNU General Public License
  19. ; along with this program.  If not, see <http://www.gnu.org/licenses/>.
  20.  
  21.  
  22. (define (script-fu-swirly-pattern qsize angle times)
  23.   (define (whirl-it img drawable angle times)
  24.     (if (> times 0)
  25.         (begin
  26.           (plug-in-whirl-pinch RUN-NONINTERACTIVE img drawable angle 0.0 1.0)
  27.           (whirl-it img drawable angle (- times 1)))))
  28.  
  29.   (let* ((hsize (* qsize 2))
  30.          (img-size (* qsize 4))
  31.          (img (car (gimp-image-new img-size img-size RGB)))
  32.          (drawable (car (gimp-layer-new img img-size img-size
  33.                                         RGB-IMAGE "Swirly pattern"
  34.                                         100 NORMAL-MODE))))
  35.  
  36.     (gimp-context-push)
  37.  
  38.     (gimp-image-undo-disable img)
  39.     (gimp-image-add-layer img drawable 0)
  40.  
  41.     ; Render checkerboard
  42.  
  43.     (gimp-context-set-foreground '(0 0 0))
  44.     (gimp-context-set-background '(255 255 255))
  45.  
  46.     (plug-in-checkerboard RUN-NONINTERACTIVE img drawable 0 qsize)
  47.  
  48.     ; Whirl upper left
  49.  
  50.     (gimp-rect-select img 0 0 hsize hsize CHANNEL-OP-REPLACE 0 0)
  51.     (whirl-it img drawable angle times)
  52.     (gimp-invert drawable)
  53.  
  54.     ; Whirl upper right
  55.  
  56.     (gimp-rect-select img hsize 0 hsize hsize CHANNEL-OP-REPLACE 0 0)
  57.     (whirl-it img drawable (- angle) times)
  58.  
  59.     ; Whirl lower left
  60.  
  61.     (gimp-rect-select img 0 hsize hsize hsize CHANNEL-OP-REPLACE 0 0)
  62.     (whirl-it img drawable (- angle) times)
  63.  
  64.     ; Whirl lower right
  65.  
  66.     (gimp-rect-select img hsize hsize hsize hsize CHANNEL-OP-REPLACE 0 0)
  67.     (whirl-it img drawable angle times)
  68.     (gimp-invert drawable)
  69.  
  70.     ; Terminate
  71.  
  72.     (gimp-selection-none img)
  73.     (gimp-image-undo-enable img)
  74.     (gimp-display-new img)
  75.  
  76.     (gimp-context-pop)
  77.   )
  78. )
  79.  
  80. (script-fu-register "script-fu-swirly-pattern"
  81.   _"_Swirly..."
  82.   _"Create an image filled with a swirly pattern"
  83.   "Federico Mena Quintero"
  84.   "Federico Mena Quintero"
  85.   "June 1997"
  86.   ""
  87.   SF-ADJUSTMENT _"Quarter size"             '(20 0 2048 1 10 0 1)
  88.   SF-ADJUSTMENT _"Whirl angle"              '(90 0 360 1 1 0 0)
  89.   SF-ADJUSTMENT _"Number of times to whirl" '(4 0 128 1 1 0 1)
  90. )
  91.  
  92. (script-fu-menu-register "script-fu-swirly-pattern"
  93.                          "<Image>/File/Create/Patterns")
  94.